package com.lpfy.dtxc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * @author: hanGuangHui
 * @data: 2024/3/13
 * @description:
 */
public class ExitBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e("--------onReceive",intent.getAction());
        if (intent.getAction().equals(Intent.ACTION_SHUTDOWN) ||
                intent.getAction().equals(Intent.ACTION_REBOOT)) {
            // 在此处添加需要执行的代码，比如启动一个Service
            Intent serviceIntent = new Intent(context, MyService.class);
            context.startService(serviceIntent);
        }
    }
}